package com.kasax.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.kasax.lifecycle.BaseActLifecycleObserver

open abstract class BaseActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        if (getLayoutId() == 0) {
            throw RuntimeException("getLayoutId() must be implemented")
        }

        setContentView(getLayoutId())

        lifecycle.addObserver(BaseActLifecycleObserver(this))

        initView()
        addListeners()
        initData()

    }

    open fun initData() {
    }

    open fun addListeners() {
    }

    open fun initView() {
    }

    abstract fun getLayoutId(): Int
}